﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PricePortalLib
{
    public class IItemImpl : IItem
    {
        private uint subSupplier;
        private ulong partNumer;
        private string description;
        private DateTime hit;

        public IItemImpl(uint subSupplier, ulong partNumber, string description, DateTime hit)
        {
            this.subSupplier = subSupplier;
            this.partNumer = partNumber;
            this.description = description;
            this.hit = hit;
        }

        public uint SubSupplier
        {
            get { return subSupplier; }
            set { this.subSupplier = value; }
        }

        public ulong PartNumber
        {
            get { return partNumer; }
            set { this.partNumer = value; }
        }

        public string Description
        {
            get { return description; }
            set { this.description = value; }
        }

        public DateTime Hit
        {
            get { return hit; }
            set { this.hit = value; }
        }

        public override bool Equals(object obj)
        {
            if (obj == null) return false;

            if (this == obj) return true;

            if (this.GetType() != obj.GetType()) return false;

            // safe because of the GetType check
            var item = (IItemImpl)obj;

            if (!hit.Equals(item.hit)) 
                return false;

            if (!description.Equals(item.description)) 
                return false;

            if (!partNumer.Equals(item.partNumer))
                return false;

            if (!subSupplier.Equals(item.subSupplier))
                return false;

            return true;
        } 
    }
}
